﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Microsoft.Practices.ServiceLocation;
using MvcFckEditor.Components;
using MvcMall.Core.Contacts.Services;

namespace MvcMall.Portal.Controllers.Extensions
{
    public class FCKEditorProvider : FckProvider
    {
        public override string GetUserFilesPath()
        {
            HttpContext context = HttpContext.Current;
            var fileService = ServiceLocator.Current.GetInstance<IFileService>();
            if (context.User != null && context.User.Identity.IsAuthenticated)
            {
                //当然我需要在这里对用户名是否符合文件夹规则做个判断，这里只是一个例子，大家可以用用户ID或其他方法实现
                return fileService.GetUserFilePath(context.User.Identity.Name);
            }
            else
            {
                return fileService.GetSysFilePath();
            }
        }
    }
}
